using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PlatfromShoot
{
    public class Player : MonoBehaviour
    {
        // 声明刚体
        private Rigidbody2D mRig;
        private float mGroundMoveSpeed = 5f;  // 地面移动速度
        private float MJumpForce = 12f;

        private void Start() {
            mRig = GetComponent<Rigidbody2D>();
        } 
        private void FixedUpdate() {
            // 跳跃
            if (Input.GetKeyDown(KeyCode.Space))  // 检测是否按下空格键
            {
                mRig.velocity = new Vector2(mRig.velocity.x, MJumpForce);  // 跳跃x轴不发生变动 y发生变化
            }

            mRig.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * mGroundMoveSpeed, mRig.velocity.y);  // 对象 - ad 左右进行移动
        }
    }
}
